/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.account.Key.CosBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.SingleValueMod;
/*    */ import com.zimbra.cs.account.Cos;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CosId
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object attrValue, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 35 */     validateCosId(attrsToModify, attrName);
/*    */   }
/*    */   
/*    */   private void validateCosId(Map attrsToModify, String attrName) throws ServiceException
/*    */   {
/* 40 */     AttributeCallback.SingleValueMod mod = singleValueMod(attrsToModify, attrName);
/* 41 */     if (mod.unsetting()) {
/* 42 */       return;
/*    */     }
/* 44 */     String cosId = mod.value();
/* 45 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 51 */     if (prov.idIsUUID()) {
/* 52 */       Cos cos = prov.get(Key.CosBy.id, cosId);
/* 53 */       if (cos == null) {
/* 54 */         throw ServiceException.INVALID_REQUEST("cos id " + cosId + " does not point to a valid cos", null);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/CosId.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */